package com.chinacoal.microservice;

import com.chinacoal.microservice.fallback.DeviceManagementClientFallback;
import com.chinacoal.microservice.pojo.CcmsSmartleasingDeviceManagement;
import com.chinacoal.microservice.util.QueryCriteria;
import com.chinacoal.microservice.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 运维管理-设备管理-对外开放接口类
 * @date 2020-12-17 10：51
 */
@Api(tags = {"运维管理-设备管理"})
@FeignClient(name = "${spring.application.name}",fallback = DeviceManagementClientFallback.class,configuration = FeignAutoConfiguration.class)
public interface DeviceManagementClient {

    /**
     * @Description: 查询所有的设备信息（带分页）
     * @author zhuliang
     * @date 2020/12/17 11:20
     */
    @ApiOperation(value = "查询所有的设备信息（带分页）")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "queryCriteria", value = "查询条件实体类", required = true, dataType = "QueryCriteria"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @PostMapping("smartleasing/deviceManagement/getAllByPage")
    public Result<List<CcmsSmartleasingDeviceManagement>> getAllByPage(@RequestBody QueryCriteria queryCriteria,
                                                                       @RequestHeader("token") String token);

    /**
     * @Description: 条件查询所有的设备信息（带分页）
     * @author zhuliang
     * @date 2020/12/17 11:20
     */
    @ApiOperation(value = "条件查询所有的设备信息（带分页）")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "queryCriteria", value = "查询条件实体类", required = true, dataType = "QueryCriteria"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @PostMapping("smartleasing/deviceManagement/getAllByCondition")
    public Result<List<CcmsSmartleasingDeviceManagement>> getAllByCondition(@RequestBody QueryCriteria queryCriteria,
                                                                            @RequestHeader("token") String token);

    /**
     * @Description: 根据设备id查询设备信息
     * @author zhuliang
     * @date 2020/12/17 14:25
     */
    @ApiOperation(value = "根据设备id查询设备信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "pkDeviceManagementId", value = "设备主键id", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @GetMapping("smartleasing/deviceManagement/getDeviceById/{pkDeviceManagementId}")
    public Result<CcmsSmartleasingDeviceManagement> getDeviceById(@PathVariable(value = "pkDeviceManagementId") String pkDeviceManagementId,
                                                                  @RequestHeader("token") String token);

    /**
     * @Description: 修改设备信息
     * @author zhuliang
     * @date 2020/12/17 14:26
     */
    @ApiOperation(value = "修改设备信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "deviceManagement", value = "设备信息实体类", required = true, dataType = "CcmsSmartleasingDeviceManagement"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @PutMapping("smartleasing/deviceManagement/updateByDevice")
    public Result updateByDevice(@RequestBody CcmsSmartleasingDeviceManagement deviceManagement,
                                 @RequestHeader(value = "token") String token);

    /**
     * @Description: 添加设备信息
     * @author zhuliang
     * @date 2020/12/17 14:27
     */
    @ApiOperation(value = "添加设备信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", name = "deviceManagement", value = "设备信息实体类", required = true, dataType = "CcmsSmartleasingDeviceManagement"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @PostMapping("smartleasing/deviceManagement/addByDevice")
    public Result addByDevice(@RequestBody CcmsSmartleasingDeviceManagement deviceManagement,
                              @RequestHeader(value = "token") String token);

    /**
     * @Description: 获取云丁的token的路径信息
     * @author zhuliang
     * @date 2021/2/1 16:02
     */
    @ApiOperation(value = "获取云丁的token的路径信息")
    @GetMapping("smartleasing/deviceManagement/getYunDingTokenUrl")
    public Result getYunDingTokenUrl();

    /**
     * @Description: 获取微羽的token的路径信息
     * @author zhuliang
     * @date 2021/2/1 16:02
     */
    @ApiOperation(value = "获取微羽的token的路径信息")
    @GetMapping("smartleasing/deviceManagement/getWeiYuTokenUrl")
    public Result getWeiYuTokenUrl();

    /**
     * @Description: 获取绿米的token的路径信息
     * @author zhuliang
     * @date 2021/2/1 16:02
     */
    @ApiOperation(value = "获取绿米的token的路径信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "code", value = "绿米code", required = false, dataType = "String")
    })
    @GetMapping("smartleasing/deviceManagement/getLuMiTokenUrl")
    public Result getLuMiTokenUrl(@RequestParam(value = "code", required = false) String code);

    /**
     * @Description: 存放第三方设备token信息
     * @author zhuliang
     * @date 2021/2/1 16:49
     */
    @ApiOperation(value = "存放第三方设备token信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "yunDingToken", value = "云丁token", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "weiYuToken", value = "微羽token", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "luMiAccessToken", value = "绿米token", required = false, dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "luMiRefreshToken", value = "绿米刷新token", required = false, dataType = "String")
    })
    @PostMapping("smartleasing/deviceManagement/getThirdPartyToken")
    public Result getThirdPartyToken(@RequestParam(value = "yunDingToken", required = false) String yunDingToken,
                                     @RequestParam(value = "weiYuToken", required = false) String weiYuToken,
                                     @RequestParam(value = "luMiAccessToken", required = false) String luMiAccessToken,
                                     @RequestParam(value = "luMiRefreshToken", required = false) String luMiRefreshToken);
}
